
function insertVotingLinks(contestants){
	
	var votingLinks = "<div class='ui-list'>";
	
 	for(var i=0; i < contestants.length; i++){
		
		var encMsg = encodeURI(contestants[i].message);
				
		votingLinks += 	"<div class='ui-list-item'" +
					 	"onclick=\"mwl.loadURL('sms:"+contestants[i].number+";body="+encMsg+"');\">" +
					 	"<img class='ui-list-item-icon' src=\""+contestants[i].photo+"\"/>" +
					 	"<span class='ui-list-item-title'>Vote for "+contestants[i].name+"<span></div>";		
	}
 	
 	votingLinks += "</div>";
	
	document.getElementById("links").innerHTML = votingLinks;
	
}

function init() {
	
	
	var contestants = [
       {
       	"name": "Laura",
       	"number": "+358123456789",
       	"message": "vote 1",
       	"photo": "resources/person.png"
       },
       {
       	"name": "Bob",
       	"number": "+358123456789",
       	"message": "vote 2",
       	"photo": "resources/person.png"
       },
       {
       	"name": "Norah",
       	"number": "+358123456789",
       	"message": "vote 3",
       	"photo": "resources/person.png"
       }                    
   ];
	
	insertVotingLinks(contestants);
	
}